﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ChangePassword : System.Web.UI.Page
{
   
    string mess = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["User"] == null)
        {
            Response.Redirect("Index.aspx");
        }
    }
    protected void btnChange_Click(object sender, EventArgs e)
    {
        AccountDAO accDAO = new AccountDAO();
        if (txtOldPass.Text.Equals(accDAO.GetPassword(Session["User"].ToString())))
        {
            if (txtNewPass.Text.Equals(txtConfirm.Text))
            {
                if (accDAO.ChangePassword(Session["User"].ToString(),txtNewPass.Text) > 0)
                {
                    
                    Response.Redirect("~/Admin/Profile.aspx");
                }
                
            }
            else
            {
                mess = "Password is not match";                
            }
        }
        else
        {
            mess = "Wrong password";
        }
        lb_message.Text = mess;
    }

    protected void btnReset_Click(object sender, EventArgs e)
    {
        txtConfirm.Text = "";
        txtNewPass.Text = "";
        txtOldPass.Text = "";
    }
    protected void txtOldPass_TextChanged(object sender, EventArgs e)
    {

    }
}